#ifndef _MIPI_CSI_H_
#define _MIPI_CSI_H_

#ifdef __cplusplus
extern "C" {
#endif


//*****************************************************************************
//*****************************************************************************
//** Enumerated types
//*****************************************************************************
//*****************************************************************************

typedef enum 
{
    MIPI_CSI_DPHY_FREQ_80_90Mbps   = 0x00,
    MIPI_CSI_DPHY_FREQ_90_100Mbps  = 0x10,
    MIPI_CSI_DPHY_FREQ_100_110Mbps = 0x20,

    MIPI_CSI_DPHY_FREQ_110_125Mbps = 0x01,
    MIPI_CSI_DPHY_FREQ_125_140Mbps = 0x11,
    MIPI_CSI_DPHY_FREQ_140_150Mbps = 0x21,

    MIPI_CSI_DPHY_FREQ_150_160Mbps = 0x02,
    MIPI_CSI_DPHY_FREQ_160_180Mbps = 0x12,
    MIPI_CSI_DPHY_FREQ_180_200Mbps = 0x22,

    MIPI_CSI_DPHY_FREQ_200_210Mbps = 0x03,
    MIPI_CSI_DPHY_FREQ_210_240Mbps = 0x13,
    MIPI_CSI_DPHY_FREQ_240_250Mbps = 0x23,

    MIPI_CSI_DPHY_FREQ_250_270Mbps = 0x04,
    MIPI_CSI_DPHY_FREQ_270_300Mbps = 0x14,
    MIPI_CSI_DPHY_FREQ_300_330Mbps = 0x24,//datasheet the same as DPHY_FREQ_250_270Mbps

    MIPI_CSI_DPHY_FREQ_330_360Mbps = 0x15,
    MIPI_CSI_DPHY_FREQ_360_400Mbps = 0x25,

    MIPI_CSI_DPHY_FREQ_400_450Mbps = 0x06,
    MIPI_CSI_DPHY_FREQ_450_500Mbps = 0x16,

    MIPI_CSI_DPHY_FREQ_500_550Mbps = 0x07,
    MIPI_CSI_DPHY_FREQ_550_600Mbps = 0x17,

    MIPI_CSI_DPHY_FREQ_600_650Mbps = 0x08,
    MIPI_CSI_DPHY_FREQ_650_700Mbps = 0x18,

    MIPI_CSI_DPHY_FREQ_700_750Mbps = 0x09,
    MIPI_CSI_DPHY_FREQ_750_800Mbps = 0x19,

    MIPI_CSI_DPHY_FREQ_800_850Mbps = 0x0a,
    MIPI_CSI_DPHY_FREQ_850_900Mbps = 0x1a,

    MIPI_CSI_DPHY_FREQ_900_950Mbps = 0x2a,
    MIPI_CSI_DPHY_FREQ_950_1000Mbps = 0x3a
}MIPI_CSI_DPHY_FREQ_RANGE_E;

typedef enum
{
    //YUV
    MIPI_CSI_IPI_DATA_TYPE_YUV420_8BIT         = 0x18,
    MIPI_CSI_IPI_DATA_TYPE_YUV420_10BIT        = 0x19,
    MIPI_CSI_IPI_DATA_TYPE_YUV420_LEGACY_10BIT = 0x1A,
    MIPI_CSI_IPI_DATA_TYPE_YUV420_8BIT_CHROMA  = 0x1C,
    MIPI_CSI_IPI_DATA_TYPE_YUV420_10BIT_CHROMA = 0x1D,
    MIPI_CSI_IPI_DATA_TYPE_YUV422_8BIT         = 0x1E,
    MIPI_CSI_IPI_DATA_TYPE_YUV422_10BIT        = 0x1F,
    //RGB
    MIPI_CSI_IPI_DATA_TYPE_RGB444 = 0x20,
    MIPI_CSI_IPI_DATA_TYPE_RGB555 = 0x21,
    MIPI_CSI_IPI_DATA_TYPE_RGB565 = 0x22,
    MIPI_CSI_IPI_DATA_TYPE_RGB666 = 0x23,
    MIPI_CSI_IPI_DATA_TYPE_RGB888 = 0x24,
    //RAW
    MIPI_CSI_IPI_DATA_TYPE_RAW6  = 0x28,
    MIPI_CSI_IPI_DATA_TYPE_RAW7  = 0x29,
    MIPI_CSI_IPI_DATA_TYPE_RAW8  = 0x2A,
    MIPI_CSI_IPI_DATA_TYPE_RAW10 = 0x2B,
    MIPI_CSI_IPI_DATA_TYPE_RAW12 = 0x2C,
    MIPI_CSI_IPI_DATA_TYPE_RAW14 = 0x2D
}MIPI_CSI_IPI_DATE_TYPE_E;

typedef enum
{
    MIPI_CSI_IPI_COLOR_MODE_48BITS = 0,
    MIPI_CSI_IPI_COLOR_MODE_16BITS
}MIPI_CSI_IPI_COLOR_MODE_BITS_E;

typedef enum
{
    MIPI_CSI_IPI_MODE_CAMERA_TIMING = 0,
    MIPI_CSI_IPI_MODE_CONTROLLER_TIMING
}MIPI_CSI_IPI_MODE_E;

typedef enum
{
    MIPI_CSI_ACTIVE_LANE_1 = 0,
    MIPI_CSI_ACTIVE_LANE_2,
    MIPI_CSI_ACTIVE_LANE_3,
    MIPI_CSI_ACTIVE_LANE_4,
}MIPI_CSI_ACTIVE_LANE_E;

//*****************************************************************************
//*****************************************************************************
//** Data Structures
//*****************************************************************************
//*****************************************************************************

typedef struct 
{
    unsigned char                  ipi_vcid;
    MIPI_CSI_ACTIVE_LANE_E         mipi_lanes;
    MIPI_CSI_DPHY_FREQ_RANGE_E     dphy_freq_range;
    MIPI_CSI_IPI_COLOR_MODE_BITS_E ipi_color_mode_bits;
    MIPI_CSI_IPI_MODE_E            ipi_mode;
    MIPI_CSI_IPI_DATE_TYPE_E       ipi_data_type;

    // the video Horizontal Synchronism Active (HSA) time
    unsigned int video_hsa_time;
    //video Horizontal Back Porch (HBP) time
    unsigned int video_hbp_time;
    //video Horizontal Sync Delay (HSD) time.
    unsigned int video_hsd_time;
    //the overall time for each video line
    unsigned int video_hline_time;
    // the Vertical Synchronism Active (VSA) period.
    unsigned int video_vsa_lines;
    //the Vertical Back Porch (VBP) period.
    unsigned int video_vbp_lines;
    //the Vertical Front Porch (VFP) period
    unsigned int video_vfp_lines;
    //the vertical resolution of the video.
    unsigned int video_vactive_lines;
}SGKS_MIPI_CSI_CONFIG_T;

#ifdef __cplusplus
}
#endif

#endif